﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FineSoft.Models
{
	public class HtmlElement : System.Collections.Specialized.NameValueCollection
	{
		public readonly string TagName;

		public string InnerHtml;

		public HtmlElement(string tagName)
		{
			this.TagName = tagName;
		}

		public override string ToString()
		{
			string s = "<" + this.TagName;
			foreach (string key in this.AllKeys)
				s += " " + key + "=\"" + this[key] + '"';
			s += ">" + this.InnerHtml + "</" + this.TagName + ">";
			return s;
		}

		public HtmlElement(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
			: base(info, context)
		{
			this.TagName = info.GetString("TagName");
			this.InnerHtml = info.GetString("InnerHtml");
		}

		public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("TagName", this.TagName);
			info.AddValue("InnerHtml", this.InnerHtml);
		}
	}
}